//
//  KnowledgeViewModei.m
//  DeepBreathing
//
//  Created by rimi on 15/12/17.
//  Copyright © 2015年 rimi. All rights reserved.
//

#import "KnowledgeViewModei.h"
#import "KnowledgeModel.h"
#import "NetworkManger.h"
#import <UIKit/UIKit.h>

@interface KnowledgeViewModei ()

@property(nonatomic,strong)KnowledgeModel *model;

@end

@implementation KnowledgeViewModei

-(NSArray *)dataFromModel{
    
//    NSLog(@"%@",self.model.knowledge[@"data"][@"result"]);
    
    return self.model.knowledge[@"data"][@"result"];
}

-(NSInteger)numberOfRows{
    
    return [[self dataFromModel] count];
    
}
-(NSString *)cellTitleAtIndexPath:(NSIndexPath *)indexPath{
    
    return [self dataFromModel][indexPath.section][@"title"];
    
}
-(NSString *)cellDateAtIndexPath:(NSIndexPath *)indexPath{
    
//     NSLog(@"%@",[self dataFromModel][indexPath.section][@"createTime"]);
    
    return [self dataFromModel][indexPath.section][@"createTime"];
   
    
}
-(NSURL *)cellImageUrlAtIndexPath:(NSIndexPath *)indexPath{
    
    NSString *urlstring = [self dataFromModel][indexPath.section][@"pic"];
    return [NSURL URLWithString:[BASE_URL stringByAppendingString:urlstring]];
    
}

-(NSString *)IdOftheKnowledge:(NSIndexPath *)indexPath{
    
  
    return [self dataFromModel][indexPath.section][@"id"];
   
}



-(KnowledgeModel *)model{
    
    
    if (!_model) {
        _model = [[KnowledgeModel alloc]init];
    }
    return _model
    ;
    
       
}

-(void)getData{
    
    [self.model getData];
}
-(void)getMoreData{
    [self.model getMoreData];
}


-(NSString *)observeringKeyPath{
    
    return @"model.knowledge";
    
    
}


-(BOOL)isSuccess{
    return ![self.model.knowledge isKindOfClass:[NSNull class]];
}


@end
